package com.sdleyou.treepro.manager.api.tree;

import com.sdleyou.treepro.common.model.dto.TreeDTO;
import com.sdleyou.treepro.common.model.utils.ResultVOUtil;
import com.sdleyou.treepro.common.model.vo.ResultVO;
import com.sdleyou.treepro.common.service.TreeManager;
import com.sdleyou.treepro.system.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 树木信息控制器
 */
@RestController
@RequestMapping("/api")
public class ManagerTreeController {
    @Autowired
    private TreeManager treeManager;

    /**
     * 创建树木信息
     *
     * @param treeDTO
     * @return
     */
    @ApiVersion(1)
    @PostMapping("/{version}/manager/tree")
    public ResultVO createTree(@RequestBody TreeDTO treeDTO) {
        treeManager.createTree(treeDTO);
        return ResultVOUtil.success();
    }

    /**
     * 修改树木信息
     *
     * @param treeDTO
     * @param treeId
     * @return
     */
    @ApiVersion(1)
    @PutMapping("/{version}/manager/tree/{tree_id}")
    public ResultVO updateTree(@RequestBody TreeDTO treeDTO,
                               @PathVariable("tree_id") String treeId) {
        treeManager.updateTree(treeDTO, treeId);
        return ResultVOUtil.success();
    }

    /**
     * 添加树成长值与图片比例
     */
    @ApiVersion(1)
    @PutMapping("/{version}/manager/tree/createTreeImgProportion")
    public ResultVO createTreeImgProportion() {
        treeManager.createTreeImgProportion();
        return ResultVOUtil.success();
    }
}
